﻿namespace SvGame.Logic;

public static partial class GameLogic
{
    private static readonly string GmToken = "7u8i9o0p";
    public static (G2CGmAction, EProtocolResult) C2GGmAction(C2GGmAction req)
    {
        var rsp = new G2CGmAction();
        var rst = EProtocolResult.成功;

        if (req.Token != GmToken)
        {
            rst = EProtocolResult.管理员登陆密码错误; return (rsp, rst);
        }
        if (!GetPlayer(req.Uid.ToLong(), out var player))
        {
            rst = EProtocolResult.玩家不存在; return (rsp, rst);
        }
        switch (req.Action)
        {
            case "货币添加":
                if (req.Args.Count >= 2)
                {
                    player.AddMoney((EMoneyType)(req.Args[0].ToInt()), req.Args[1].ToLong());
                    player.NtfPlayerInfo();
                }
                break;
            case "道具添加":
                if (req.Args.Count >= 2)
                {
                    player.AddItem(req.Args[0].ToInt(), req.Args[1].ToLong());
                    player.NtfPlayerItems();
                }
                break;
            default:
                rst = EProtocolResult.错误的修改类型; return (rsp, rst);
        }

        return (rsp, rst);
    }
}
